<extend name="Public/layout"/>

<block name="style">
    <style type="text/css">
        @media (min-width: 992px) {
            .form select,
            .form textarea,
            .form input[type=text],
            .form input[type=password],
            .form .token-input-list{
                width: 50% !important;
                max-width: 600px;
            }
        }
    </style>
</block>

<block name="body">
    <div class="row">
        <div class="col-xs-12">
            <form action="__SELF__" method="post" class="form">
                <div class="tab-content">
                    <div class="blank"></div>
                    <div class="form-group">
                        <label class="item-label">上级分类<span class="check-tips">（所属的上级分类）</span></label>
                        <div class="controls">
                            <select name="pid" class="form-control">
                                <volist name="all_group" id="group">
                                    <option value="{$group.id}" 
                                <php>if($group['id'] == $info['pid']) echo 'selected="selected"';</php> >
                                {$group.title_show}
                                </option>
                            </volist>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="item-label">分类名称<span class="check-tips">（分类名称）</span></label>
                        <div class="controls">
                            <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="item-label">图标<span class="check-tips">（分类图标）</span></label>
                        <div class="controls">
                            <div id="upload_1"></div>
                            <div id="preview">
                                <input type="hidden" name="cover" value="{$info.cover}">
                                <img style="margin-top:8px;max-height:60px;" src="{$info.cover|get_cover}">
                            </div>
                            <script type="text/javascript">
                                $(function () {
//                                    修复新添加商品，默认图片为空显示无效破碎图片问题
                                    function check_img() {
                                        var value = $('#preview input').attr('value');
                                        
                                        if (value == '0') {
                                            $('#preview img').hide();
                                        } else {
                                            $('#preview img').show();
                                        }
                                    }
                                    check_img();
                                    $('#upload_1').Huploadify({
                                    uploader:'{:U("Upload/upload")}',
                                            fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                                            fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')} * 1024,
                                            buttonText:'上 传 图 片',
                                            onUploadComplete:function(file, data){
                                            var data = $.parseJSON(data);
                                            $('#preview img').attr('src', data.url);
                                            $('#preview input').attr('value', data.id);
                                            }
                                });
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="item-label">主页显示<span class="check-tips">（是否在首页显示）</span></label>
                        <div class="controls">
                            <select name="show_index" class="form-control">
                                <volist name="show_index_option" id="item" key="k">
                                    <option value="{$k-1}" 
                                <php>if($info['show_index'] == $k-1) echo 'selected="selected"';</php> >
                                {$item}
                                </option>
                            </volist>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="item-label">排序<span class="check-tips">（用于分类显示的顺序）</span></label>
                        <div class="controls">
                            <input type="text" class="form-control" name="sort" value="{$info.sort|default=0}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input type="hidden" name="id" value="{$info.id|default=''}">
                <button class="btn btn-primary submit ajax-post" type="submit" target-form="form">确 定</button>
                <button class="btn return" onclick="javascript:history.back(-1);
                                return false;">返 回</button>
            </div>
    </form>
</div>
</div>
</block>

